package com.huang.computer.controller;


import com.huang.computer.entity.Student;
import com.huang.computer.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/student")
public class StudentController {
    @Autowired
    IStudentService iStudentService;
    @GetMapping
    public String loginPage(){
        return "/student/login";
    }

    @PostMapping("/login")
    public String QueryStudentlogin(@RequestParam String username, @RequestParam String passwd,
                                  HttpSession session){
        Student student = iStudentService.Studentlogin(username, passwd);
        if (student!=null){
            session.setAttribute("username",username);
            return "/kk";
        }else{
            return "/index";
        }
    }
}

